//
//  CollectionBaseCell.swift
//  JFDouYu
//
//  Created by xujf on 2018/1/8.
//  Copyright © 2018年 XuJF. All rights reserved.
//

import UIKit

class CollectionBaseCell: UICollectionViewCell {
    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var onlineBtn: UIButton!
    @IBOutlet weak var nickNameLabel: UILabel!
    
    var anchor : AnchorModel?{
        didSet{
            guard let anchor  = anchor  else { return}
            
            //1.取出在线人数显示的文字
            var onlineStr : String = ""
            
            if anchor.online >= 10000 {
                onlineStr = "\(anchor.online / 10000)万在线"
            }else{
                onlineStr = "\(anchor.online)在线"
            }
            
            onlineBtn.setTitle(onlineStr, for:.normal)
            
            //昵称
            nickNameLabel.text = anchor.nickname
            
            //设置封面
            guard let iconURL = URL(string : anchor.vertical_src) else {
                return
            }
            iconImageView.kf.setImage(with: iconURL)
            
            
        }
    }
    
}
